<?php
	class Student
	{
		var $student_id;
		var $student_username;
		var $student_password;
		var $student_firstname;
		var $student_lastname;
		var $student_ncuid;
		var $student_faculty;
		var $student_year;
		var $student_email;
		var $student_tel;
		
		
		public function getStudentId()
		{
			return $this->student_id;
		}
		public function setStudentId($student_id)
		{	
			$this->student_id=$student_id;
		}


		public function getStudentUsername()
		{
			return $this->student_username;
		}
		public function setTeacherUsername($student_username)
		{
			$this->student_username=$student_username;
		}


		public function getStudentPassword()
		{
			return $this->student_password;
		}
		public function setStudentPassword($student_password)
		{
			$this->student_password=$student_password;
		}
		
		public function getStudentFirstname()
		{
			return $this->student_firstname;
		}
		public function setStudentFirstname($student_firstname)
		{
			$this->student_firstname=$student_firstname;
		}

		public function getStudentLastname()
		{
			return $this->student_lastname;
		}
		public function setStudentLastname($student_lastname)
		{
			$this->student_lastname=$student_lastname;
		}

		public function getStudentNcuId()
		{
			return $this->student_ncuid;
		}
		public function setStudentNcuId($student_studentid)
		{
			$this->student_ncuid=$student_ncuid;
		}
		
		public function getStudentFaculty()
		{
			return $this->student_faculty;
		}
		public function setStudentFaculty($student_faculty)
		{
			$this->student_faculty=$student_faculty;
		}

		public function getStudentYear()
		{
			return $this->student_year;
		}
		public function setStudentYear($student_year)
		{
			$this->student_year=$student_year;
		}

		public function getStudentEmail()
		{
			return $this->student_email;
		}
		public function setStudentEmail($student_email)
		{
			$this->student_email=$student_email;
		}

		public function getStudentTel()
		{
			return $this->student_tel;
		}
		public function setStudentTel($student_tel)
		{
			$this->student_tel=$student_tel;
		}

		public function studentLogin($studentusername,$studentpassword)
		{
			$query = mysql_query('SELECT * FROM studentmember WHERE 
			student_username = "'.$studentusername.'" AND 
			student_password = "'.$studentpassword.'" ')or die (mysql_error());

			$count = mysql_num_rows($query);
			if ($count!=0)
			{
				
				 $_SESSION['student_id'] = session_id;
				 $_SESSION['student_username'] = $studentusername;
				echo 'good';
			}
				echo "PASS";
		}
		public function studentLogout()
		{
				
		}


		public function studentRegister($student_username,$student_password,$student_firstname,$student_lastname,$student_ncuid,$student_email,$student_tel,$student_faculty,$student_year)
		{
			mysql_query('INSERT INTO studentmember (student_username,student_password,student_firstname,student_lastname,student_ncuid,student_email,student_tel,student_faculty,student_year) VALUES
			(
				"'.$student_username.'","'.$student_password.'","'.$student_firstname.'","'.$student_lastname.'","'.$student_ncuid.'","'.$student_email.'","'.$student_tel.'","'.$student_faculty.'","'.$student_year.'"
			)
			')or die(mysql_error());   
			return true;
		}
		public function studentForgotpassword($student_username,$student_firstname,$student_ncuid,$student_email)
		{
			$query = mysql_query('SELECT student_password FROM studentmember WHERE 
			student_username = "'.$student_username.'" AND
			student_firstname = "'.$student_firstname.'" AND 
			student_ncuid = "'.$student_ncuid.'" AND 
			student_email = "'.$student_email.'" LIMIT 1')or die (mysql_error());

			$count = mysql_fetch_array($query);
			if ($count!=0)
			{
				echo "";
			}
			return $count['student_password'];
		}
		public function studentEditOwnProfile($student_firstname,$student_lastname,$student_email,$student_tel,$student_id)
		{
				mysql_query('UPDATE studentmember SET student_firstname = "'. $student_firstname .'" , student_lastname = "'. $student_lastname .'",student_email = "'. $student_email .'", student_tel = "'. $student_tel .'" WHERE student_id="'. $student_id .'" LIMIT 1')or die(mysql_error());
		}
		public function studentShowprofile()
		{
			$query = mysql_query('SELECT * FROM studentmember') or die(mysql_error()); 

			$data_array = array(); 

			while($arr = mysql_fetch_object($query)) 
				{
				
					$data_array[$arr->student_id]['student_id'] = $arr->student_id; 
					$data_array[$arr->student_id]['student_username'] = $arr->student_username; 
					$data_array[$arr->student_id]['student_firstname'] = $arr->student_firstname; 
					$data_array[$arr->student_id]['student_lastname'] = $arr->student_lastname;
					$data_array[$arr->student_id]['student_ncuid'] = $arr->student_ncuid;
					$data_array[$arr->student_id]['student_faculty'] = $arr->student_faculty;
					$data_array[$arr->student_id]['student_year'] = $arr->student_year;
					$data_array[$arr->student_id]['student_email'] = $arr->student_email;
					$data_array[$arr->student_id]['student_tel'] = $arr->student_tel;
					
				} 
			echo json_encode($data_array); 
		}
		public function studentShowFullprofile()
		{
			$query = mysql_query('SELECT * FROM studentmember WHERE student_username = "'. $_GET['student_username'] .'" ') or die(mysql_error()); 

			$data_array = array(); 

			while($arr = mysql_fetch_object($query)) 
				{
				
					$data_array[$arr->student_id]['student_id'] = $arr->student_id; 
					$data_array[$arr->student_id]['student_username'] = $arr->student_username; 
					$data_array[$arr->student_id]['student_firstname'] = $arr->student_firstname; 
					$data_array[$arr->student_id]['student_lastname'] = $arr->student_lastname;
					$data_array[$arr->student_id]['student_ncuid'] = $arr->student_ncuid;
					$data_array[$arr->student_id]['student_faculty'] = $arr->student_faculty;
					$data_array[$arr->student_id]['student_year'] = $arr->student_year;
					$data_array[$arr->student_id]['student_email'] = $arr->student_email;
					$data_array[$arr->student_id]['student_tel'] = $arr->student_tel;
					
				} 
			echo json_encode($data_array); 
		}
		public function studentShowFullInf()
		{
			$query = mysql_query('SELECT * FROM main_information WHERE  inf_id = "'. $_GET['inf_id'] .'"') or die(mysql_error()); 

			$data_array = array(); 

			while($arr = mysql_fetch_object($query)) 
				{
				
					$data_array[$arr->inf_id]['inf_id'] = $arr->inf_id; 
					$data_array[$arr->inf_id]['inf_title'] = $arr->inf_title; 
					$data_array[$arr->inf_id]['inf_subject'] = $arr->inf_subject; 
					$data_array[$arr->inf_id]['inf_date_start'] = $arr->inf_date_start;
					$data_array[$arr->inf_id]['inf_date_end'] = $arr->inf_date_end;
					$data_array[$arr->inf_id]['inf_detail'] = $arr->inf_detail;
					$data_array[$arr->inf_id]['inf_faculty'] = $arr->inf_faculty;
					$data_array[$arr->inf_id]['inf_type'] = $arr->inf_type;
					$data_array[$arr->inf_id]['inf_user'] = $arr->inf_user;
					
				} 
			echo json_encode($data_array); 

		}
	}
?>